<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<ul id="riskTab" class="contListTab mt10">
    <li class="selectContListTab" onclick="javascript:$('#productsListMenu').click();"><a href="javascript:void(0);">Publish Products</a></li>
    <li onclick="javascript:product.list(0);"><a href="javascript:void(0);">Products List</a></li>
</ul>
<div id="riskTabCnt">
    <div class="pad10">
        <ul class="mode_add">
            <li><input type="hidden" id="productId"/></li>
            <li><label>New Release:</label><input type="checkbox" id="newReleaseProduct"/></li>
            <li><label>Product Category:</label><select id="categoriesList" style="width: 150px;height: 20px;"></select></li>
            <li><label>Part No.:</label><input type="text" id="productNumber" class="input_txt" size="60"/></li>
            <li><label>Name:</label><input type="text" id="productName" class="input_txt" size="60"/></li>
            <li><label>Spec.:</label><input type="text" id="productSpec" class="input_txt" size="60"/></li>
            <li class="wrap_flow">
                <label style="float:left">Image:</label>
                <div style="padding-left: 118px;">
	                <form method="POST" enctype="multipart/form-data" id="productImageForm" style="float:left;"> 
	                    <input type="hidden" name="filePath" value="file/productPicture"/>
	                    <input type="hidden" name="width" value="264"/>
	                    <input type="hidden" name="height" value="230"/>
	                    <input type="file" name="file" id="file" onchange="javascript:$('#productImageForm').submit();"/>
	                </form>
                    <font style="float:left;" color="red">Image Size: 264 x 230</font>
                </div>
                <input type="hidden" id="productFilePath"/>
            </li>
            <li>
                <label>Image Preview:</label>
                <img style="width:264px;height:230px;" id="productImage" src="">
            </li>
            <li class="clearall">
                <label class="fleft">Product Readme:</label>
                <div style="padding-left:110px;">
                    <textarea class="xheditor" id="productReadme" name="productReadme" style="width:630px;height:300px;"></textarea>
                </div>
            </li>
            <li>
                <label>&nbsp;</label>
                <input type="button" id="publishProductButton" value="Add" class="blueBtn" />
            </li>
        </ul>
    </div>
    <div class="pad10" style="display: none;">
        <table class="listTable tac mar10">
            <thead>
                <tr>
                    <th>Number</th>
                    <th>Name</th>
                    <th>Spec</th>
                    <th>Category</th>
                    <th>Create Date</th>
                    <th>New Release</th>
                    <th>Operation</th>
                </tr>
            </thead>
            <tbody id="productList">
            </tbody>
        </table>
        <br/>
        <div id="paginationDiv"></div>
    </div>
</div>

<script type="text/javascript" src="js/product.js"></script>
<script type="text/javascript" src="js/upload.js"></script>
<script type="text/javascript">
    //切换
    switchTab("riskTab","riskTabCnt","div","selectContListTab");
    
    upload.uploadImage('product');
    
    product.categoriesListByParentId(-1,0,'categoriesList');

    var editor = $('#productReadme').xheditor({upImgUrl:"../xheditor/uploadImage?filePath=/file/productPicture/",upImgExt:"jpg,jpeg,gif,png"});

    var productId = '<%=request.getParameter("productId")%>';

    if(productId!=null&&productId!='null'){
    	$('#publishProductButton').click(function(){
    		product.create('update');
        });
        product.modify(productId);
    }else{
        $('#publishProductButton').click(function(){
            product.create('create');
        });
    }
</script>
